package com.ddm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ddm.entity.vxEntity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface WebAdminMapper extends BaseMapper<User> {
    /*
   管理员查询相关代码
   */
    @Select("SELECT * FROM user WHERE user_name LIKE CONCAT('%', #{name}, '%') AND user_type = 1")
    List<User> findAdminsByName(String name);

    @Select("SELECT * FROM user WHERE user_type = 1")
    List<User> findAllAdmins();

    @Select("SELECT * FROM user WHERE id = #{id} AND user_type = 1")
    User findAdminById(Long id);

    User selectUserById(Long id);

    @Update("UPDATE user SET deleted = #{newDeleted} WHERE id = #{id}")
    int updateUserDeletedById(@Param("id") Long id, @Param("newDeleted") Integer newDeleted);
}